<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
        <ui:define name="content">
            <h:panelGroup id="messagePanel" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            <h:form prependId="false" id ="display">
                <p:messages/>
                <p:panel header="Information for this invoice: " style="text-align: left">
                    <h:panelGrid columns="2" > 

                        <h:outputText value="From:" />
                        <br/>
                        <br />
                        <h:outputText value="#{vendorInvoiceEntityController.text}" />
                        <br />

                        <h:outputText value="#{vendorInvoiceEntityController.address.streetAddress}" />
                        <br/>

                        <h:outputText value="#{vendorInvoiceEntityController.address.city}" />                
                        <br/>
                        <h:outputText value="#{vendorInvoiceEntityController.address.stateOrProvice}"  />
                        <br/>

                        <h:outputText value="#{vendorInvoiceEntityController.address.country}"  />
                        &nbsp;
                        <h:outputText value="#{vendorInvoiceEntityController.address.zipCode}"  />
                        <br />
                        <p:separator style="width:500px;height:3px" />

                        <br/>
                        <br/>
                        <p:panel header="Information for this invoice: ">
                            <h:panelGrid columns="2" id="grid">  
                                <h:outputLabel for="id" value="Invoice Id: &nbsp;" />  
                                <p:inputText value="#{vendorInvoiceEntityController.id}"  
                                             id="id" required="true" label="id" />  



                                <h:outputText value="Total nominal Cost:($S) &nbsp;"/>

                                <p:inputText value="#{vendorInvoiceEntityController.cost}" required="true" label="text"/>


                                <h:outputText value="Tax amount:($S)  &nbsp;"/>

                                <p:inputText value="#{vendorInvoiceEntityController.taxAmount}" required="true" label="text"/>


                                <h:outputLabel for="total" value="Total amount due($S): &nbsp;"/>

                                <p:inputText value="#{vendorInvoiceEntityController.amount}" id ="total" required="true" label="total"/>






                                <h:outputText value="Date Received: &nbsp;"/>

                                <p:calendar value="#{vendorInvoiceEntityController.date1}" showOn="button" />     


                                <h:outputText value="Due date: &nbsp;"/>

                                <p:calendar value="#{vendorInvoiceEntityController.dueDate}" showOn="button"/>   

                            </h:panelGrid>
                        </p:panel>
                    </h:panelGrid> 
                </p:panel>
                <p:separator/>




                <p:panel header="All Shipment schedule of this order:" >  
                    <p:dataTable id="availableCars" value="#{vendorInvoiceEntityController.list}" var="entry" 
                                 >


                        <p:column  >
                            <f:facet name="header">  
                                <h:outputText value="Date" />  
                            </f:facet>  
                            <h:outputText value="#{entry.date}">
                                <f:convertDateTime pattern="dd/MM/yyyy" />
                            </h:outputText>

                        </p:column>
                        <p:column >

                            <f:facet name="header">  
                                <h:outputText value="Amount" />  
                            </f:facet>  
                            <h:outputText value="#{entry.amount}"/>


                        </p:column>
                        <p:column style="width:32px">  
                            <p:commandButton value ="Assign" update="books msgs @parent" process="@this" 
                                             >  
                                <f:setPropertyActionListener value="#{entry}"  
                                                             target="#{vendorInvoiceEntityController.selectedSchedule}" />  
                                <p:collector value="#{vendorInvoiceEntityController.selectedSchedule}"
                                             addTo="#{vendorInvoiceEntityController.droppedSchedule}" />
                            </p:commandButton>  
                        </p:column>  

                    </p:dataTable>
                </p:panel>  
                <p:separator /> 
                <p:panel header="Shipment corresponds to this invoice is:">
                    <p:outputPanel id="books">  
                        <p:dataTable value="#{vendorInvoiceEntityController.droppedSchedule}" var="pur"  >
                            <p:column  >
                                <f:facet name="header">  
                                    <h:outputText value="Date" />  
                                </f:facet>  
                                <h:outputText value="#{pur.date}">
                                    <f:convertDateTime pattern="dd/MM/yyyy" />
                                </h:outputText>

                            </p:column>
                            <p:column >

                                <f:facet name="header">  
                                    <h:outputText value="Amount" />  
                                </f:facet>  
                                <h:outputText value="#{pur.amount}"/>


                            </p:column>
                            <p:column style="width:32px"> 
                                <f:facet name="header">  
                                    <h:outputText value="Operations" />  
                                </f:facet>  
                                <p:commandButton value ="Remove" update="books msgs @parent">

                                    <f:setPropertyActionListener value="#{pur}"  
                                                                 target="#{vendorInvoiceEntityController.selectedSchedule}" />  
                                    <p:collector value="#{vendorInvoiceEntityController.selectedSchedule}"
                                                 removeFrom="#{vendorInvoiceEntityController.droppedSchedule}" />
                                </p:commandButton>  
                            </p:column>  


                        </p:dataTable>  
                    </p:outputPanel>  
                </p:panel>
                <br/>

                <p:commandButton action= "#{vendorInvoiceEntityController.create}"  value="Create Invoice" update="growl"/>   
                <p:commandButton action="#{vendorInvoiceEntityController.recreateModel}" ajax="false" value="Back" />  


            </h:form>
        </ui:define>
    </ui:composition>

</html>